package com.mgq.juc.design.order.v3;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * @author MaGuangQi
 * 使用park,unpark
 * @date 2021-12-17 11:37
 **/
@Slf4j
public class OrderPrintV3 {
    public static void main(String[] args) {
        Thread t2 = new Thread(() -> {
            LockSupport.park();
            log.debug("我负责打印2");
        }, "t2");

        Thread t1 = new Thread(() -> {
            log.debug("我负责打印1");
            LockSupport.unpark(t2);
        }, "t1");

        t1.start();
        t2.start();

    }
}
